﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RooHui.Infrastructure.Entities.Repository;
using RooHui.Infrastructure.Entities.Enum;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class AgentProfitStream : IAccessible<P_AgentProfitStream, AgentProfitStream>, ILogicEntity<P_AgentProfitStream, AgentProfitStream>
    {
        public int Id { get; set; }
        public string UserName { get; set; }
        public ProfitStreamType Type { get; set; }
        public string Invester { get; set; }
        public int InvestmentId { get; set; }
        public SettlementType SettlementType { get; set; }
        public decimal Settlement { get; set; }
        public decimal Profit { get; set; }
        public DateTime RecordDate { get; set; }

        public AgentInfo AgentInfo { get; set; }
        public Member InvesterUser { get; set; }
        public Investment Investment { get; set; }

        public AgentProfitStream LoadAgetInfo(P_AgentInfo p_agentInfo)
        {
            this.AgentInfo = new AgentInfo().Set(p_agentInfo);
            return this;
        }

        public AgentProfitStream LoadInvesterUser(P_Member p_member)
        {
            this.InvesterUser = new Member().Set(p_member);
            return this;
        }

        public AgentProfitStream LoadInvestment(P_Investment p_investment, P_Project p_project)
        {
            this.Investment = new Investment().Set(p_investment);
            this.Investment.Project = new Project().Set(p_project);
            return this;
        }


        protected override void Covariant(P_AgentProfitStream model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.UserName = model.UserName;
                this.Type = (ProfitStreamType)model.Type;
                this.Invester = model.Invester;
                this.InvestmentId = model.InvestmentId;
                this.SettlementType = (SettlementType)model.SettlementType;
                this.Settlement = model.Settlement;
                this.Profit = model.Profit;
                this.RecordDate = model.RecordDate;
            }
        }

        protected override P_AgentProfitStream Inverter(AgentProfitStream model)
        {
            if (model != null)
            {
                return new P_AgentProfitStream()
                {
                    Id = model.Id,
                    Invester = model.Invester,
                    InvestmentId = model.InvestmentId,
                    SettlementType=(int)model.SettlementType,
                    Settlement=model.Settlement,
                    Profit = model.Profit,
                    RecordDate = model.RecordDate,
                    Type = (int)model.Type,
                    UserName = model.UserName
                };
            }
            return null;
        }

        public AgentProfitStream Set(P_AgentProfitStream dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
